home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / piw131.zip / MULTIIDW.H < prev    next >
Text File  |  1994-07-29  |  23KB  |  498 lines

  1. // ------- MultiIDW.h  Multiple-precision integer decimal algorithms
  2. /*
  3.   Version : Version 3.11, last revised: 1994-07-29, 0600 hours
  4.   Author  : Copyright (c) 1981-1994 by author: Harry J. Smith,
  5.   Address : 19628 Via Monte Dr., Saratoga, CA 95070.  All rights reserved.
  6. */
  7.  
  8. #ifndef MultiID_H
  9. #define MultiID_H
  10.  
  11. #include <iostream.h>
  12. #include <alloc.h>
  13. #include <stdio.h>     // FILE
  14. #include <fstream.h>   // ofstream etc.
  15. #include "iomanip.h"   // setw()
  16. #include <dos.h>
  17.  
  18. // Developed in Turbo C++ 1.0.  Converted to Borland C++ 3.0 for Windows.
  19. // In Turbo C++ 1.0 etc. the max odd integer to store in a float is
  20. // 2**24-1 = 167,77215; for a double is 2**53-1 = 9,00719,92547,40991
  21.  
  22. #define False  0
  23. #define True   1
  24. #define Plus   0
  25. #define Minus  1
  26. #define nL     '\n'
  27. #define dL     "\n\n"
  28. #define MuDMax 7         // Max number of decimal digits in a super digit
  29. #define MuNMax 300000000L// Max number of super digits in a multi-precision #
  30.           // Each super digit is from 0 to 9999999, i.e. Base = 10**7
  31. typedef float  Mu1Digit; // Can hold + or - integer <= Base
  32. typedef double Mu2Digit; // Can hold + or - integer <= Base squared + Base
  33. typedef int    Bool;     // Boolean, has a value of True = 1 or False = 0
  34. typedef int    Sign;     // Has a value of Minus = 1 or Plus = 0
  35. typedef int    TriS;     // Tristate, has a value of -1: <0. 0: =0, +1: >0
  36. typedef Mu1Digit huge *VPtr;  // Value, LSD at index 0
  37. typedef double Real;          // Real type used in FFT
  38. typedef long double RealPlus; // Extended Real type used in FFT
  39. typedef union {               // Array elements used in FFT
  40.   double v;                   //
  41.   char cV[8];                 //
  42. } bytes8;                     //
  43. typedef union {               // Array elements used in convolution
  44.   long double v;              //   to get 16 byte elements vice 10 for
  45.   char cV[16];                //   long doubles memory fetch problem
  46. } bytes16;                    //   work-around for arrays > 65536 bytes
  47.  
  48. //extern ostream& OutP[2]; // { cout, cLog } ; // OutP[i] << i << nL; did not
  49.                            // a.WritLn( OutP[i]);  work???
  50.  
  51. // ------- The following are set when the InitMulti is called
  52. extern Mu2Digit Base;     // Radix of multi-precision numbers, 10**MuDMax
  53. extern Mu1Digit MaxDigit; // Base - 1
  54. extern Mu2Digit BaseSq;   // Base squared
  55. extern Mu2Digit BSMB;     // (BaseSq - Base) for MuDiv and MuSqRt
  56. extern RealPlus Pi;       // Pi
  57. extern RealPlus Pi2;      // 2 * Pi
  58. // ------ The following can be tested by user
  59. extern Bool MuErr;        // Boolean, True if multi-precision error occurred
  60. extern Bool MuAbort;      // Boolean, True if Mu procedure interrupted by user
  61. extern Bool SoftAbort;    // Boolean, True if SoftAbort Flag set by operator
  62. extern Bool KeyHit;       // Boolean, True if KeyPressed has been cleared
  63. extern char KeyCh;        // Key input when KeyPressed was cleared
  64. // ------- The following can be changed by user
  65. extern Bool Echo;         // 1 if in Echo output to printer mode, 0 otherwise
  66. extern Bool MuDOnly;      // True if only raw digits of a number are to be output
  67. extern int  MuDpG;        // Digits per group in number output display >= 1 or 0
  68. extern int  MuLenD;       // Min length in digits to display length in digits
  69. extern Bool MuErrRep;     // True if multi-precision error reports are desired
  70. extern long MMax;         // Max number of super digits <= MuNMax
  71. extern long TracN;        // Number if iterations of an innermost loop
  72. extern long Trace;        // Number of "Digits" left to compute
  73. extern long ShortN;       // If > 0 then Short format desired from x.Writ( Out)
  74. extern Bool DiagOn;       // Diagnostics turned on
  75. extern double TV0;        // Dos time value at time zero for diag
  76. extern double TV1;        // Dos time value for delta time, TV2 - TV1
  77. extern double TV2;        // Dos time value for total time, TV2 - TV0
  78. extern double TV3;        // Dos time value for start of a time-out period
  79. extern double Del0;       // Total time from TV0
  80. extern double Del1;       // Delta time from last Diag call
  81. extern double DosClockP;  // Previous value of Dos clock for day cycle test
  82. extern int DosDays;       // Number of days to add to Dos clock
  83. extern int MuMaxW;        // Max number of characters to write on a line
  84. extern int MuTot;         // Total number of characters on the line so far
  85. extern VPtr huge ProtV;   // Pointer to protected Value being returned from +..
  86. extern ofstream Disk;     // Text file, output
  87. extern ofstream LogF;     // Text file, Log output file
  88. extern struct date da;    // Defined in DOS.h, initialized in InitMulti
  89. // int  da_year;          // current year      use GetDateTime(); to fill this
  90. // char da_day;           // day of the month
  91. // char da_mon;           // month (1 = Jan) 
  92. extern struct  time ti;
  93. // unsigned char ti_min;  // minutes           use GetDateTime(); to fill this
  94. // unsigned char ti_hour; // hours 
  95. // unsigned char ti_hund; // hundredths of seconds 
  96. // unsigned char ti_sec;  // seconds
  97.  
  98. // ------- A multiple-precision unsigned integer
  99. class MultiUI {
  100. public:
  101.   long N;      // Current length in super digits, 1..MuNMax
  102.   long M;      // Max number of super digits ever in this number
  103.   VPtr huge V; // string of super digits, Value, LSD at index 0
  104.  
  105.   // ------- CONSTRUCTORS
  106.  
  107.   // ------- constructor for a null MultiUI
  108.   MultiUI() { N = 0;  M = 0;  V = NULL; }
  109.   // -------- constructor with just a max size
  110.   MultiUI( long NMaxI);
  111.  
  112.   // ------- DESTRUCTOR
  113.  
  114.   ~MultiUI() { if (V == NULL)  ;
  115.            else {
  116.          if (V == ProtV)  ProtV = NULL;
  117.            else {
  118.          farfree(V);  V = NULL; }}}
  119.  
  120.   // ------- MEMBER FUNCTIONS
  121.  
  122.   void NMax( long NMaxI); // Change M = NMaxI
  123.   virtual void Clear() { N = 1; V[0] = 0; } // Clear, set this value = 0
  124.   void SetTo( MultiUI& X); // Set this to X, this = X
  125.   void Norm();             // Normalize this
  126.   void RAdd( MultiUI& X);  // this = this + X
  127.   void RSub( MultiUI& X);  // this = this - X
  128.   void Add( MultiUI& X, MultiUI& Y); // this:= X + Y
  129.   void Sub( MultiUI& X, MultiUI& Y); // this:= X - Y
  130.   TriS AbComp( MultiUI& X); // AbComp = signum( |this| - |X|), signum function
  131.   Bool ZTest();             // Boolean, True if this is Zero
  132.   Bool EQ1( Mu1Digit D1);   // Boolean, True if |this| = D1
  133.   Bool GT1( Mu1Digit D1);   // Boolean, True if |this| > D1
  134. };
  135.  
  136. // ------- A multiple-precision signed integer
  137. class MultiSI : public MultiUI {
  138. public:
  139.   Sign S; // Has a value of Minus = 1 or Plus = 0
  140.  
  141.   // ------- CONSTRUCTORS
  142.  
  143.   // ------- constructor for a null MultiUI
  144.   MultiSI() : MultiUI() { S = Plus; }
  145.   // -------- constructor with just a max size
  146.   MultiSI( long NMaxI) : MultiUI( NMaxI) { S = Plus; }
  147.  
  148.   // ------- DESTRUCTOR
  149.  
  150.   ~MultiSI() {;}
  151.  
  152.   // ------- MEMBER FUNCTIONS
  153.  
  154.   virtual void Clear() { MultiUI::Clear(); S = Plus; } // Set value = 0
  155.   void ChS();              // Change sign, this = 0 - this
  156.   void SetTo( MultiSI& X); // this:= X
  157.   void Norm();             // Normalize
  158.   void RAdd( MultiSI& X);  // this:= this + X
  159.   void RSub( MultiSI& X);  // this:= this - X
  160.   void Add( MultiSI& X, MultiSI& Y); // this:= X + Y
  161.   void Sub( MultiSI& X, MultiSI& Y); // this:= X - Y
  162.   void Value( char *St, int& i);
  163.     // Convert String to 'this', returns i = # of character used
  164.   void SetTo1( Mu1Digit D1); // this = D1 Mod Base
  165.   void SetToD( double Db);   // this = Db Mod Base**4
  166.   void Get1( Mu1Digit& D1);  // D1 = this Mod Base
  167.   void GetD( double& Db);    // Db = this Mod Base**4
  168.   void RAdd1( Mu1Digit D1);  // this = this + D1
  169.   void Add1( MultiSI& X, Mu1Digit D1); // this = X + D1
  170.   TriS Comp( MultiSI& X);// Comp = signum( this - X), signum function = -1,0,+1
  171.   void Writ( ostream& Out);   // Output this as a line of text
  172.   void WritLn( ostream& Out); // Output this and a new line
  173.   void ShortWr( ostream& Out, long Short);
  174.     // Output this in short form ... if more than Short digits
  175.   void ShortWrLn( ostream& Out, long Short);
  176.     // Output this short and a new line
  177.   void RMul1( Mu1Digit D1); // this = this * D1
  178.   void Mul1( MultiSI& X, Mu1Digit D1); // this = X * D1
  179.   void Mul( MultiSI& X, MultiSI& Y);   // this = X * Y
  180.   void MulSlow( MultiSI& X, MultiSI& Y); // this = X * Y, Slow
  181.   void MulCon( MultiSI& X, MultiSI& Y);  // this = X * Y, Convolution
  182.   void MulTran( MultiSI& X, MultiSI& Y); // this = X * Y, Transform
  183.   void RMul( MultiSI& X); // this = this * X
  184.   void Sq( MultiSI& X);   // this = X * X
  185.   void RSq(); // this = this * this
  186.   void PowMB( MultiSI& B, MultiSI& P); // this = (B ** P) Mod MuMB
  187.   void RPowMB( MultiSI& P); // this = (this ** P) Mod MuMB
  188.   void ModMB();             // this = this Mod MuMB
  189.   void RDiv1( Mu1Digit D1); // this = this / D1
  190.   void Div1( MultiSI& U, Mu1Digit D1);      // this = U / D1
  191.   void Mod1( Mu1Digit D1, Mu1Digit& R1);    // R1 = Rem( this / D1)
  192.   void RDiv1QR( Mu1Digit D1, Mu1Digit& R1); // this = this / D1, R1 = Rem
  193.   void Div1QR( MultiSI& U, Mu1Digit D1, Mu1Digit& R1);// this = U/D1, R1 = Rem
  194.   void Divi( MultiSI& U, MultiSI& D);    // this = U / D
  195.   void DivSlow( MultiSI& U, MultiSI& D); // this = U / D
  196.   void DivFast( MultiSI& U, MultiSI& D); // this = U / D
  197.   void RDiv( MultiSI& D);                // this = this / D
  198.   void Modu( MultiSI& U, MultiSI& D);    // this = Rem(U / D)
  199.   void RMod( MultiSI& D);                // this = Rem( this / D)
  200.   void DivQR( MultiSI& U, MultiSI& D, MultiSI& R);     // this = U / D, R = Rem
  201.   void DivQRSlow( MultiSI& U, MultiSI& D, MultiSI& R); // this = U / D, R = Rem
  202.   void DivQRFast( MultiSI& U, MultiSI& D, MultiSI& R); // this = U / D, R = Rem
  203.   void RDivQR( MultiSI& D, MultiSI& R);             // this = this / D, R = Rem
  204.   void GCD( MultiSI& A, MultiSI& B);     // this = Greatest common divisor A, B
  205.   void RGCD( MultiSI& A);   // this=Greatest common divisor A, this
  206.   void FacMB( MultiSI& X);  // this = (X !) Mod MuMB = 1*2*3*...*X
  207.   void RFacMB();            // this = (this !) Mod MuMB = 1*2*3*...*X
  208.   void SqRtRem( MultiSI& X, MultiSI& R);     // this = SqRt(X), R = Rem
  209.   void SqRtRemSlow( MultiSI& X, MultiSI& R); // this = SqRt(X), R = Rem
  210.   void SqRtRemFast( MultiSI& X, MultiSI& R); // this = SqRt(X), R = Rem
  211.   void RSqRtRem( MultiSI& R);                // this = SqRt( this), R = Rem
  212.   void SqRoot( MultiSI& X);                  // this = SqRt(X)
  213.   void RSqRt();                              // this = SqRt( this)
  214.   void ReadSI( FILE* R, char* Name, int& OK); // Read MultiSI from a file
  215.   MultiSI operator+ (MultiSI& X);  // overloaded + infix add operator
  216.   MultiSI operator- (MultiSI& X);  // overloaded - infix sub operator
  217.   MultiSI operator* (MultiSI& X);  // overloaded * infix mul operator
  218.   MultiSI operator/ (MultiSI& X);  // overloaded / infix div operator
  219.   MultiSI operator% (MultiSI& X);  // overloaded % infix mod operator
  220.   MultiSI operator^ (MultiSI& X);  // overloaded ^ infix xor operator, => power
  221.   MultiSI operator^ (double p);    // overloaded ^ infix xor operator, => power
  222.   MultiSI operator- ();            // overloaded - unary minus operator
  223.   inline MultiSI& operator<<= (MultiSI& X);//overloaded <<= assignment operator
  224.   inline MultiSI& operator<<= (double D);  //overloaded <<= assignment operator
  225.   inline MultiSI& operator<<= (float F);   //overloaded <<= assignment operator
  226.   inline MultiSI& operator<<= (long L);    //overloaded <<= assignment operator
  227.   inline MultiSI& operator<<= (int i);     //overloaded <<= assignment operator
  228.   inline MultiSI& operator<<= (char *St);  //overloaded <<= assignment operator
  229.   inline MultiSI& operator>>= (MultiSI& X);//overloaded >>= assign. op. => swap
  230.   inline MultiSI& operator|= (MultiSI& X); //overloaded |= minimal memory copy
  231.   inline MultiSI& operator|= (double D);   //overloaded |= min mem assign op
  232.   inline MultiSI& operator|= (float F);    //overloaded |= min mem assign op
  233.   inline MultiSI& operator|= (long L);     //overloaded |= min mem assign op
  234.   inline MultiSI& operator|= (int i);      //overloaded |= min mem assign op
  235.   inline MultiSI& operator|= (char *St);   //overloaded |= min mem assign op
  236.   inline MultiSI& operator&= (long L);     //overloaded &= op. => NMax(L)
  237.   inline MultiSI& operator+= (MultiSI& X); //overloaded += replace add operator
  238.   inline MultiSI& operator-= (MultiSI& X); //overloaded -= replace sub operator
  239.   inline MultiSI& operator*= (MultiSI& X); //overloaded *= replace mul operator
  240.   inline MultiSI& operator/= (MultiSI& X); //overloaded /= replace div operator
  241.   inline MultiSI& operator%= (MultiSI& X); //overloaded %= replace mod operator
  242.   inline MultiSI& operator++ (); // overloaded ++ unary Replace add 1 operator
  243.   inline MultiSI& operator-- (); // overloaded -- unary Replace sub 1 operator
  244.   inline Bool operator<  (MultiSI& X); // overloaded <  .LT. operator
  245.   inline Bool operator<= (MultiSI& X); // overloaded <= .LE. operator
  246.   inline Bool operator>  (MultiSI& X); // overloaded >  .GT. operator
  247.   inline Bool operator>= (MultiSI& X); // overloaded >= .GE. operator
  248.   inline Bool operator== (MultiSI& X); // overloaded == .EQ. operator
  249.   inline Bool operator!= (MultiSI& X); // overloaded != .NE. operator
  250.   inline Bool operator! (); // overloaded ! unary boolean op. not, True iff 0
  251.   inline Bool operator~ (); // overloaded ~ unary boolean op. !!, False iff 0
  252. };
  253.  
  254. // ------- MultiSI's inline methods
  255.  
  256. // ------- overloaded <<= assignment operator for MultiSI <<= MultiSI
  257. inline MultiSI& MultiSI::operator<<= (MultiSI& X)
  258.   { SetTo(X);  return *this; }
  259. // (X <<= Y <<= Z; OK)
  260. // & needed on return type so this->V will not be destructed (freed)
  261. // These did not actually get compiled in-line but may on a later compiler
  262. // Was compiled as a near call vice a far call though
  263.  
  264. // ------- overloaded <<= assignment operator for MultiSI <<= double
  265. inline MultiSI& MultiSI::operator<<= (double D)
  266.   { SetToD(D);  return *this; }
  267.  
  268. // ------- overloaded <<= assignment operator for MultiSI <<= float
  269. inline MultiSI& MultiSI::operator<<= (float F)
  270.   { SetToD( (double)F);  return *this; }
  271.  
  272. // ------- overloaded <<= assignment operator for MultiSI <<= long
  273. inline MultiSI& MultiSI::operator<<= (long L)
  274.   { SetToD( (double)(L));  return *this; }
  275.  
  276. // ------- overloaded <<= assignment operator for MultiSI <<= int
  277. inline MultiSI& MultiSI::operator<<= (int i)
  278.   { SetTo1( (float)(i));  return *this; }
  279.  
  280. // ------- overloaded <<= assignment operator for MultiSI <<= string
  281. inline MultiSI& MultiSI::operator<<= (char *St)
  282.   { int i;  Value( St, i);  return *this; }
  283.  
  284. // ------- overloaded >>= assignment operator for MultiSI swap
  285. inline MultiSI& MultiSI::operator>>= (MultiSI& X)
  286.   { MultiSI T = X;  X = *this;  *this = T;  T.V = NULL;  return *this; }
  287.  
  288. // ------- overloaded |= => minimal memory copy
  289. inline MultiSI& MultiSI::operator|= (MultiSI& X)
  290.   { if (V == X.V)  NMax(X.N);  else  { NMax(0);  SetTo(X); }  return *this; }
  291.  
  292. // ------- overloaded |= minimal memory assignment op for MultiSI |= double
  293. inline MultiSI& MultiSI::operator|= (double D)
  294.   { NMax(4);  SetToD(D);  NMax(N);  return *this; }
  295.  
  296. // ------- overloaded |= minimal memory assignment op for MultiSI |= float
  297. inline MultiSI& MultiSI::operator|= (float F)
  298.   { NMax(4);  SetToD( (double)F);  NMax(N);  return *this; }
  299.  
  300. // ------- overloaded |= minimal memory assignment op for MultiSI |= long
  301. inline MultiSI& MultiSI::operator|= (long L)
  302.   { NMax(2);  SetToD( (double)(L));  NMax(N);  return *this; }
  303.  
  304. // ------- overloaded |= minimal memory assignment op for MultiSI |= int
  305. inline MultiSI& MultiSI::operator|= (int i)
  306.   { NMax(1);  SetTo1( (float)(i));  NMax(N);  return *this; }
  307.  
  308. // ------- overloaded |= minimal memory assignment op for MultiSI |= string
  309. inline MultiSI& MultiSI::operator|= (char *St)
  310.   { NMax(40);  int i;  Value( St, i);  NMax(N);  return *this; }
  311.  
  312. // ------- overloaded &= op. => NMax(L)
  313. inline MultiSI& MultiSI::operator&= (long L)
  314.   { NMax(L);  if (!M) {S = Plus;}  return *this; }
  315.  
  316. // ------- overloaded += assignment operator for replace add += MultiSI
  317. inline MultiSI& MultiSI::operator+= (MultiSI& X)
  318.   { RAdd(X);  return *this; }
  319.  
  320. // ------- overloaded -= assignment operator for replace sub -= MultiSI
  321. inline MultiSI& MultiSI::operator-= (MultiSI& X)
  322.   { RSub(X);  return *this; }
  323.  
  324. // ------- overloaded *= assignment operator for replace mul *= MultiSI
  325. inline MultiSI& MultiSI::operator*= (MultiSI& X)
  326.   { RMul(X);  return *this; }
  327.  
  328. // ------- overloaded /= assignment operator for replace div /= MultiSI
  329. inline MultiSI& MultiSI::operator/= (MultiSI& X)
  330.   { RDiv(X);  return *this; }
  331.  
  332. // ------- overloaded %= assignment operator for replace mod %= MultiSI
  333. inline MultiSI& MultiSI::operator%= (MultiSI& X)
  334.   { RMod(X);  return *this; }
  335.  
  336. // ------- overloaded ++ unary operator for MultiSI ( X++ same as ++X )
  337. inline MultiSI& MultiSI::operator++ () // Replace add 1
  338. { RAdd1(1.0);  return *this; }
  339.  
  340. // ------- overloaded -- unary operator for MultiSI ( X-- same as --X )
  341. inline MultiSI& MultiSI::operator-- () // Replace subtract 1
  342. { RAdd1(-1.0);  return *this; }
  343.  
  344. // ------- overloaded < less than operator for MultiSI
  345. inline Bool MultiSI::operator< (MultiSI& X)
  346.   { return Comp(X) < 0; }
  347.  
  348. // ------- overloaded <= operator for MultiSI
  349. inline Bool MultiSI::operator<= (MultiSI& X)
  350.   { return Comp(X) <= 0; }
  351.  
  352. // ------- overloaded > operator for MultiSI
  353. inline Bool MultiSI::operator> (MultiSI& X)
  354.   { return Comp(X) > 0; }
  355.  
  356. // ------- overloaded >= operator for MultiSI
  357. inline Bool MultiSI::operator>= (MultiSI& X)
  358.   { return Comp(X) >= 0; }
  359.  
  360. // ------- overloaded == operator for MultiSI
  361. inline Bool MultiSI::operator== (MultiSI& X)
  362.   { return Comp(X) == 0; }
  363.  
  364. // ------- overloaded != operator for MultiSI
  365. inline Bool MultiSI::operator!= (MultiSI& X)
  366.   { return Comp(X) != 0; }
  367.  
  368. // ------- overloaded ! unary boolean operator for MultiSI
  369. inline Bool MultiSI::operator! () // 0 => True, else False
  370. { return ZTest(); }
  371.  
  372. // ------- overloaded ~ unary boolean operator for MultiSI
  373. inline Bool MultiSI::operator~ () // 0 => False, else True
  374. { return !ZTest(); }
  375.  
  376. // --end-- MultiSI's inline methods
  377.  
  378. // ------- The following is initialized in module MultiIDW.Cpp
  379. extern MultiSI MuMB; // Multi-precision modulo base, 0 => normal arith.
  380.  
  381. // ------- Other services
  382.  
  383. Bool HeapOk(); // ------- Check far heap
  384.  
  385. // ------- Diag for a MultiSI
  386. void DiagSI( char* St, MultiSI& X);
  387.  
  388. // ------- Fatal error handler
  389. void FatalErr( char error_text[]);
  390.  
  391. // ------- overloaded sqrt function for MultiSI
  392. inline MultiSI sqrt( MultiSI& X)  // Not actually done inline, gives warning
  393.   { MultiSI T, Rem;  T.SqRtRem(X, Rem);  ProtV = T.V;  return T; }
  394.  
  395. // ------- Allocates a bytes8 vector with range [nl..nh]
  396. bytes8 huge *vector8( long nl,  long nh);
  397.  
  398. // ------- Frees a bytes8 vector allocated by vector8()
  399. void free_vector8( bytes8 huge *v,  long nl,  long nh);
  400.  
  401. // ------- FFT of complex type data
  402. void four1( bytes8 huge *data,  long nn,  Bool isign);
  403.  
  404. // ------- Two FFTs of real data for the price of one
  405. void twofft( bytes8 huge *data1,  bytes8 huge *data2,  bytes8 huge *fft1,
  406.          bytes8 huge *fft2,   long n);
  407.  
  408. // ------- FFT of real data
  409. void realft( bytes8 huge *data,  long n,  Bool isign);
  410.  
  411. // ------- Convolves or deconvolves a real data set (see page 430)
  412. void convlv( bytes8 huge *data,    long n,
  413.          bytes8 huge *respns,  long m,
  414.          Bool isign,           bytes8 huge *ans,
  415.          bytes8 huge *fft);
  416.  
  417. // ------- MuWriteErr, write error statement and set error flag
  418. void MuWriteErr( char *St);
  419.  
  420. // ------- Read in string from an istream, allow a blank line
  421. void ReadSt( istream& In, char *St);
  422.  
  423. // ------- Read in string from the key board, allow a blank line
  424. void ReadSt( char *St);
  425.  
  426. // ------- Read in a long integer from keyboard
  427. void ReadLInt( char *Mess, long Min, long Max, long Nom,
  428.            long& II);
  429.  
  430. // ------- Read in an integer from keyboard
  431. void ReadInt( char *Mess, int Min, int Max, int Nom, int& II);
  432.  
  433. void MuSetMMax( int NRegs); // ------- Set MMax using MemAvail
  434.  
  435. void MuInterrupt(); // ------- Test for ESC key pressed to abort operation
  436.  
  437. // ------- DosClock, get the value of the Dos clock in total seconds
  438. //         Only good to 0.01 seconds, must call earlier once each day
  439. double DosClock();
  440.  
  441. // ------- Save start time of a "Time-Out" period not to be timed
  442. void TimeOut();
  443.  
  444. // ------- Adjust TV1 time at end of a "Time-Out" period not to be timed
  445. void TimeIn();
  446.  
  447. // ------- Output a diagnostic message with delta times
  448. void Diag( char *Mess);
  449.  
  450. // ------- Log output of diagnostic message with delta times
  451. void DiagL( ostream& LogF, char *Mess);
  452.  
  453. // ------- Output String and a new line every MuMaxW,
  454. //         MuTot = characters on line so far
  455. void WriteMax( ostream& Out, char *St);
  456.  
  457. // ------- Output String and line feed every MuMaxW, and a new line
  458. //         MuTot = characters on line so far
  459. void WriteMaxLn( ostream& Out, char *St);
  460.  
  461. // ------- overloaded << operator for MultiSI output
  462. inline ostream& operator<< (ostream& Out, MultiSI& X)
  463.   { X.Writ( Out);  return Out; }
  464.  
  465. // ------- overloaded >> operator for MultiSI
  466. inline istream& operator>> (istream& In, MultiSI& X)
  467.   { char St[81];  int i;  ReadSt( In, St);  X.Value( St, i);  return In; }
  468.  
  469. // ------- overloaded <<= assignment operator for int <<= MultiSI
  470. inline int& operator<<= (int& i, MultiSI& X)
  471.   { Mu1Digit D1;  X.Get1( D1);  i = (int) D1;  return i; }
  472.  
  473. // ------- overloaded <<= assignment operator for long <<= MultiSI
  474. inline long& operator<<= (long& L, MultiSI& X)
  475.   { double Db;  X.GetD( Db);  L = (long) Db;  return L; }
  476.  
  477. // ------- overloaded <<= assignment operator for float <<= MultiSI
  478. inline float& operator<<= (float& f, MultiSI& X)
  479.   { Mu1Digit D1;  X.Get1( D1);  f = (float) D1;  return f; }
  480.  
  481. // ------- overloaded <<= assignment operator for double <<= MultiSI
  482. inline double& operator<<= (double& Db, MultiSI& X)
  483.   { X.GetD( Db);  return Db; }
  484.  
  485. // ------- Output Date and time output stream
  486. void OutDateTime(ostream& Out);
  487.  
  488. // ------- Get Date and time
  489. void GetDateTime();
  490.  
  491. void InitMulti(); // ------- Initialize Multi-precision package
  492.  
  493. // --end-- Other services
  494.  
  495. #endif  // ifndef MultiID_H
  496.  
  497. // --end-- MultiIDW.h  Multiple-precision integer decimal algorithms
  498.